package cn.arikeky.fallback;

import cn.arikeky.domain.User;
import cn.arikeky.dto.BuyDto;
import cn.arikeky.exception.GlobalExceptionEnum;
import cn.arikeky.feign.MoveService;
import cn.arikeky.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MoveServiceFallbackFactory implements FallbackFactory<MoveService> {

    @Override
    public MoveService create(Throwable throwable) {
        return new MoveService() {
            @Override
            public JsonResult list() {
                return JsonResult.error(GlobalExceptionEnum.FALLBACK);
            }

            @Override
            public JsonResult get(Long movieId) {
                return JsonResult.error(GlobalExceptionEnum.BUY_MOVE);
            }

            @Override
            public JsonResult buyMovie(Long movieId, Integer count) {
                return JsonResult.error(GlobalExceptionEnum.FALLBACK);
            }

            @Override
            public JsonResult give(Long movieId, Integer count, Long userId) {
                return JsonResult.error(GlobalExceptionEnum.GIVE_ERROR);
            }

            @Override
            public JsonResult use(Long id) {
                return JsonResult.error(GlobalExceptionEnum.USE_ERROR);
            }

//            @Override
//            public JsonResult get(Long id) {
//                return JsonResult.error(GlobalExceptionEnum.FALLBACK);
//            }
        };
    }
}